package com.aierjun.notepad;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * Created by Administrator on 2016/6/24.
 */
public class DBhelper extends SQLiteOpenHelper {

    public static final String CREATE_TEST="create table test("
            +"id integer primary key autoincrement,"
            +"accounts text,"
            +"password text)";


    protected  Context  context;

    public DBhelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        this.context=context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TEST);
        Toast.makeText(context,"进入成功",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int i, int i1) {
       /* db.execSQL("drop table exists test");
        Toast.makeText(context,"更新成功",Toast.LENGTH_SHORT).show();
        onCreate(db);*/
    }

    /*private SQLiteDatabase getDatabase(){
        SQLiteDatabase db=null;
        try{
            db=getWritableDatabase();
        }catch (SQLException e){
            Log.e("aierjun","数据库操作失败");
            e.printStackTrace();
        }
        return db;
    }*/

}
